#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    int t = 0, num = 0;
    cin >> t;
    
    while(t--)
    {
        cin >> num;
        while(num > 0)
        {
            if(num == 1)
            {
                cout << "NO" << endl;
                goto end;
            }
            for(int i = 2; i <= sqrt(num); ++i)
            {
                if(num % i == 0)
                {
                    cout << "NO" << endl;
                    goto end;
                }
            }
            num /= 10;
        }
        cout << "YES" << endl;
        end:
        ;
    }
    return 0;
}